package top.lingkang.fas.admin.dto;

import com.mybatisflex.core.paginate.Page;
import top.lingkang.fas.common.dto.R;
import top.lingkang.fas.common.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lingkang
 * created by 2025/7/20 4:37
 */
public class PageResult<T> extends R {
    public PageResult(int code, Object data) {
        super(code, data);
    }

    public static <T> PageResult<T> ok(Page page) {
        Map<String, Object> map = new HashMap<>();
        map.put("pageNumber", page.getPageNumber());
        map.put("pageSize", page.getPageSize());
        map.put("totalRow", page.getTotalRow());
        map.put("totalPage", page.getTotalPage());
        map.put("list", page.getRecords());
        return new PageResult<>(HttpStatus.SUCCESS, map);
    }

}
